package com.zhika.zishi.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhika.zishi.R;
import com.zhika.zishi.beans.FanLikeBean;

import java.util.ArrayList;

/**
 * Created by shi-02 on 2015/4/17.
 */
public class FanLikeAdapter extends BaseAdapter {

    private Context context;

    private ArrayList<FanLikeBean> fanLikeList;

    public FanLikeAdapter(Context context,ArrayList<FanLikeBean> fanLikeList){
        this.context = context;
        this.fanLikeList = fanLikeList;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public int getCount() {
        return fanLikeList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView == null){
            view = LayoutInflater.from(context).inflate(R.layout.item_of_fan_like,null);
            holder = new ViewHolder();

            holder.headerImageView = (ImageView) view.findViewById(R.id.item_of_fan_like_header_image_view);
            holder.nicknameText = (TextView) view.findViewById(R.id.item_of_fan_like_nickname_text);
            holder.introductionText = (TextView) view.findViewById(R.id.item_of_fan_like_introduction_text);

            view.setTag(holder);
        }else {
            view = convertView;
            holder = (ViewHolder) view.getTag();
            resetViewHolder(holder);
        }

        FanLikeBean bean = fanLikeList.get(position);

        //设置头像
//        holder.headerImageView.setImageBitmap();

        holder.nicknameText.setText(bean.getNicknameStr());
        holder.introductionText.setText(bean.getIntroductionStr());

        return view;

    }

    private void resetViewHolder(ViewHolder holder){
        holder.headerImageView.setImageBitmap(null);

        holder.nicknameText.setText(null);

        holder.introductionText.setText(null);
    }
    private class ViewHolder{
        private ImageView headerImageView;

        private TextView nicknameText;

        private TextView introductionText;
    }
}
